<?php

namespace App\Http\Requests\Setting;

use App\Http\Requests\FormRequest;

class MenuStoreRequest extends FormRequest
{
    public function rules(): array
    {
        return [
            'type' => 'required|integer|in:1,2,4',
            'pid' => 'required|integer',

            'title' => 'required|string|max:20',
            'path' => 'nullable|string|max:30',
            'redirect_path' => 'nullable|string|max:30',

            'code' => 'required_unless:type,4|max:20',
            'component' => 'required_unless:type,4|max:40',
            'icon' => 'required|string|max:20',

            'keep_alive' => 'nullable|integer|in:1,0',
            'sort' => 'nullable|integer',
            'hidden' => 'required|integer|in:1,0',
            'btns' => 'nullable|array',
            'btns.*.title' => 'required|max:20',
            'btns.*.code' => 'required|max:20',
        ];
    }
}
